<?

/* GmController controller class.
 * This class contains the handling code, divided into action methods.
 *
 */ 
class MetaController extends AGController
{
  function __construct($ctrName) 
  {
    parent::__construct($ctrName);
    $this->invokeModel();
  }

  function __init()
  {
    $this->model->user = &$this->user;
    $this->model->character = &$this->character;  
  }

  function Index()
  {
    // your default action code goes here
    $this->news = DB_GetList('SELECT * FROM '.getTableName('news').' WHERE
      1
      ORDER BY n_date DESC
      LIMIT 10
      ');
  }
  
  function News()
  {
    $this->pageTitle = 'News';
    $newsId = $_REQUEST['id']+0;
    $this->news = DB_GetDataset('news', $newsId);
    if ($_REQUEST['cmd'] == 'postcomment')
    {
      $cds = array(
        'nc_news' => $this->news['n_key'],
        'nc_user' => $this->user->localRecord['u_key'],
        'nc_content' => $_REQUEST['content'],
        );
      DB_UpdateDataset('news_comments', $cds);
      AdminNotify('new comment on: '.$this->news['n_title'], strip_tags($_REQUEST['content']));
    }
    $this->comments = DB_GetList('SELECT * FROM '.getTableName('news_comments').' 
      LEFT JOIN '.getTableName('users').' ON (nc_user=u_key)
      WHERE
        nc_news="'.$this->news['n_key'].'"
      ORDER BY nc_date ASC
      ');
  }
  
  function Cheat()
  {
    $this->pageTitle = 'Cheat!';
    if (isset($_REQUEST['type']))
    {
      $_SESSION['cheatmessage'] = $this->model->applyCheat($_REQUEST['type']);
      $this->redirect('cheat', 'meta');
    }
    $this->cheatMessage = $_SESSION['cheatmessage'];
    unset($_SESSION['cheatmessage']);  
  }
  
  function Top()
  {
    $this->pageTitle = 'Top';
  }
  
  function Feedback()
  {
    $this->pageTitle = 'Feedback';
  }
}


?>
